<template>
    <div>
    <h2>登录</h2>
    <table>
        <tr>
            <td>账号</td>
            <td> <input type="text"  v-model="state.Lname" /></td>
        </tr>
        <tr>
            <td>密码</td>
            <td> <input type="password"  v-model="state.lpwd" /></td>
     
        </tr>
        <tr>
            <td>
                <input type="button" value="登录"  @click="funlogin"/>
            </td>
            <td></td>
        </tr>
    </table>
    </div>
</template>

<script setup lang="ts">

 import { reactive,toRefs, onMounted} from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import axios from 'axios'
 const route = useRoute()
 const router = useRouter()

 const data = reactive({
    state:{
        Lname:'',
        lpwd:''
    }
 })

 const {state} = toRefs(data)

const funlogin = ()=>{
    axios({
        url:'https://localhost:7144/api/Login/Login',
        method:'get',
        params:state.value
    })
    .then((res)=>{
        console.log(res)
        if(res.data.data > 0){
            alert('成功')
            router.push('show')
        }
        else{
            alert('失败')
        }
    })
    .catch((err)=>{
        console.log(err)
    })
}

</script>

<style scoped>

</style>